﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;

namespace FYPDemo
{
    public class SendMail
    {
        public static void SendEmail(string toAddress, string subject, string body)
        {
            System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
            m.From = new MailAddress("Universale.noreply@gmail.com"); //from
            String email = toAddress;
            m.To.Add(email); //to
            m.Subject = subject; //email title
            m.IsBodyHtml = true;
            m.Body = body;


            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            smtp.EnableSsl = true;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new System.Net.NetworkCredential("Universale.noreply@gmail.com", "universale123"); //send back sendiri
            
            smtp.Send(m);
        }
    }
}